package org.example;

import java.lang.reflect.Executable;
import java.util.*;
import java.util.concurrent.Executors;

public class Main {

    public static void main(String[] args) {
        System.out.println(4 >> 1);
    }

    public static boolean isValid(String s) {
        if(s.length() == 0){
            return true;
        }
        Stack<Character> stack = new Stack<>();
        char[] array = s.toCharArray();
        for(char item : array){
            if(item == ')' || item == '}' || item == ']'){
                char left = stack.peek();
                if(stack.isEmpty() || !isMatch(left, item)){
                    return false;
                }else{
                    stack.pop();
                }
            }else{
                stack.push(item);
            }
        }
        return stack.isEmpty();
    }

    public static boolean isMatch(Character left, Character right){
        return switch (right) {
            case '}' -> left == '{';
            case ')' -> left == '(';
            case ']' -> left == '[';
            default -> false;
        };
    }
}